<?php

namespace app\common\model;

use think\Db;
use think\Model;


class TradersOrder extends Model
{
    protected $insert = ['status' => 0, 'create_time', 'update_time'];
    protected $update = ['update_time'];

    /**
     * 设置添加时间
     * @return int
     */
    protected function setCreateTimeAttr()
    {
        return time();
    }

    /**
     * 设置更新时间
     * @return int
     */
    protected function setUpdateTimeAttr()
    {
        return time();
    }

    /**
     * Notes:完成订单
     * User: Administrator
     * Date: 2023/9/4
     * Time: 18:34
     * @param $id
     * @throws \think\exception\DbException
     */
    public static function finishOrder($id)
    {
        $rowInfo = self::get($id);
        $rowInfo->finish_time = time();
        $rowInfo->status = 20;
        $rowInfo->save();
    }

    /**
     * Notes:取消订单
     * User: Administrator
     * Date: 2023/9/4
     * Time: 18:36
     * @param $id
     * @throws \think\exception\DbException
     */
    public static function offTimeOrder($id)
    {
        $rowInfo = self::get($id);
        $rowInfo->status = -2;
        $rowInfo->save();
    }
}
